package com.ilioili.appframe;
import java.util.ArrayList;

import bean.Student;

import com.ilioili.app.R;

import util.bitmap.FileUtil;
import util.sql.DbHelper;
import util.sql.JsonUtil;
import util.sql.SqlUtil;
import android.os.Bundle;

public class OrmDemo extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		FileUtil.init(getApplication());
		setContentView(R.layout.activity_main);
		ArrayList<Student> list = new ArrayList<Student>();
		DbHelper.clear(Student.class);
		Student std = null;
		for(int i=0; i<100; i++){
			std = new Student();
			std.name = "Hunter";
			std.num = "080510331";
			std.score = i;
			std.sex = i%3;
			list.add(std);
		}
		DbHelper.saveList(list);
		System.out.println(SqlUtil.getSqlForCreateTable(Student.class));
		System.out.println(SqlUtil.getSqlForInsert(std));
		JsonUtil ju = new JsonUtil();
		System.out.println(ju.getJson(std, 0, true));
		System.out.println(ju.getJson(std, 1, false));
		System.out.println(ju.getObj(Student.class, ju.getJson(std, 0, false), 0));
		list = DbHelper.getList(Student.class, 50);
		for(Student s : list){
			s.name = "HanTuo";
		}
		DbHelper.updateList(list);
	}
		
}
